package org.maxgroundstation.groundstation.comm.service;

import java.util.EventObject;

/**
 * An event from a service.
 * @author Scott Davis
 * 
 * Copyright (C) 2010  Scott Davis
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@SuppressWarnings("serial")
public class ServiceEvent extends EventObject {

    // Event Types
    public static final String DATA_RECEIVED = "data received";
    
    // Data members
    private String type; // The event type.
    private Object target; // The event target object, if any.
    
    /**
     * Constructor
     * @param source the object throwing the event.
     * @param type the type of event.
     */
    public ServiceEvent(Object source, String type, Object target) {
        // Use EventObject constructor
        super(source);
        
        this.type = type;
        this.target = target;
    }
    
    /**
     * Gets the type of event.
     * @return event type
     */
    public String getType() {
        return type;
    }
    
    /**
     * Gets the target object of the event.
     * @return target object or null if none.
     */
    public Object getTarget() {
        return target;
    }
    
    /**
     * Override toString() method.
     */
    public String toString() {
        return getType();
    }
}